using System;
using System.Collections.Generic;
using System.Text;

namespace Money_Log_Mobile
{
    public class StandingOrder
    {
        public string Name;
        public double Amount;
        public StandingOrderFrequency Frequency;
        public DateTime StartDate;
        public List<string> Categories;
        public bool IsDueOn(DateTime LastStandingOrderDate)
        {
            bool StandingOrderDue = false;
            switch (Frequency)
            {
                case StandingOrderFrequency.WorkDay:
                    if (LastStandingOrderDate.DayOfWeek != DayOfWeek.Saturday || LastStandingOrderDate.DayOfWeek != DayOfWeek.Sunday)
                    {
                        StandingOrderDue = true;
                    }
                    break;
                case StandingOrderFrequency.Daily:
                    StandingOrderDue = true;
                    break;
                case StandingOrderFrequency.Weekly:
                    if (LastStandingOrderDate.DayOfWeek == StartDate.DayOfWeek)
                        StandingOrderDue = true;
                    break;
                case StandingOrderFrequency.Monthly:
                    //TODO: Work out what will happen if SO day is at end of month and this month will not hit it
                    break;
                case StandingOrderFrequency.Quarterly:
                    //TODO: WOrk this one out
                    break;
                case StandingOrderFrequency.Yearly:
                    if (LastStandingOrderDate.DayOfYear == StartDate.DayOfYear)
                    {
                        StandingOrderDue = true;
                    }
                    break;
            }
            return StandingOrderDue;
        }
    }
    public enum StandingOrderFrequency
    {
        WorkDay,
        Daily,
        Weekly,
        Monthly,
        Quarterly,
        Yearly
    }
}
